package leitores;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import principal.Ponto;
import principal.Triangulo;

public class LeitorObjeto {
	
	/*
	 	/---------------------------------------\
		| 3 1                                   | ; 3 pontos e 1 triangulo
		| 50.0000 0.0000 0.000                  | ; ponto 1: P1(50, 0, 0)
		| 0 50 0                                | ; ponto 2: P2(0, 50, 0)
		| 0 0 50                                | ; ponto 3: P3(0, 0, 50)
		| 1 2 3                                 | ; triangulo 1: formado pelos vertices 1, 2 e 3
		|                                       |
		\---------------------------------------/
	 */
	
	private File arquivo;
	private Scanner scanner;
	
	public LeitorObjeto(String arq) throws FileNotFoundException{
		this.arquivo = new File(arq);
		this.scanner = new Scanner(this.arquivo);
	}
	
	/**
	 * 
	 * @return
	 */
	public File getArquivo(){
		return this.arquivo;
	}
	
	/**
	 * 
	 * @return
	 */
	public Scanner getScanner(){
		return this.scanner;
	}
	
	/**
	 * 
	 * @return
	 */
	public int readNumeroPontos(){
		int numeroPontos = scanner.nextInt();
		return numeroPontos;
	}
	
	/**
	 * 
	 * @return
	 */
	public int readNumeroTriangulos(){
		int numeroTriangulos = scanner.nextInt();
		return numeroTriangulos;
	}
	
	/**
	 * 
	 * @param numPontos
	 * @return
	 */
	public List<Ponto> readPontos(int numPontos){
		List<Ponto> pontos = new ArrayList<Ponto>();
		for(int i = 0; i < numPontos; i++){
			double x = Double.parseDouble(this.scanner.next());
			double y = Double.parseDouble(this.scanner.next());
			double z = Double.parseDouble(this.scanner.next());
			pontos.add(new Ponto(x,y,z));
		}
		return pontos;
	}
	
	/**
	 * 
	 * @param numTriangulos
	 * @return
	 */
	public List<Triangulo> readTriangulos(int numTriangulos){
		List<Triangulo> triangulos = new ArrayList<Triangulo>();
		for(int i = 0; i < numTriangulos; i++){
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			int z = scanner.nextInt();
			triangulos.add(new Triangulo(x,y,z));
		}
		return triangulos;
	}
}